<div class="content container">
    <!-- container -->
    <!--  -->
    <section class="mark">
        <h2>
            <if condition="$ms == 2">
                <a class="btn btn-primary pull-right">其他学生</a>
                评卷
                <elseif condition="($ms == 3) AND ($exam.type eq 0)" /> 详情
                <elseif condition="($ms == 3) AND ($exam.type eq 1)" />
                <a class="btn btn-primary pull-right">其他同学</a>
                详情
            </if>
        </h2>
        <p>学生：{$list.username}</p>
        <h2>客观题分数：{$list.kgtotal}</h2>
        <a class="btn btn-primary">查看题目</a>
    </section>
    <!-- End -->
    <section class="exam-list" data-shu="{$list.kgtotal}">
        <h2>主观题分数：{$list.zgscore}</h2>
        <!-- 题目列表 -->
        <if condition="($ms == 3) AND ($exam.type eq 1)">
            <div class="exam-list-li-head">
                <div class="pull-right">
                    <if condition="$laud eq ''">
                        <a class="btn-zan pull-left"></a>
                        <else/>
                        <a class="btn-zan pull-left active"></a>
                    </if>
                    <span class="pull-left zan_num">&nbsp;{$zan_num}</span>
                </div>
                <if condition="$userid == $list['userid']">
                    <a class="pull-right" data-toggle="modal" data-target="#share">
                        <i class="btn-share pull-left"></i>&nbsp;分享到朋友圈
                    </a>
                    <else/>
                </if>
            </div>
            <br/>
        </if>
        <volist name="list['zg']" id="vo">
            <div class="exam-list-li" data-id="{$vo.id}">
                <!-- 考试-头部 -->
                <div class="exam-list-li-head">
                    <if condition="$ms == 2">
                        <div class="pull-right">
                            <label>评分</label>
                            <input id="in{$vo.id}" value="{$vo.pfs.sco}" type="number">
                        </div>
                    </if>
                    <!-- <span>2：</span> -->
                </div>
                <!-- 考试-头部 End -->
                <!-- 考试-题目 -->
                <div class="exam-list-li-text">
                    {$vo.content}
                </div>
                <!-- 考试-题目 End -->
                <!-- 考试-答案 -->
                <div class="exam-list-li-text">
                    答案：{$vo.tans}
                </div>
                <!-- 考试-答案 End -->
                <!-- 考试-评语 -->
                <div class="exam-list-li-answer">
                    <h3>老师评语</h3><br>
                    <if condition="$ms ==2">
                        <textarea id="te{$vo.id}" class="form-control" rows="3" placeholder="可以输入多行文本">{$vo.pfs.con}</textarea>
                        <elseif condition="$ms == 3" />
                        <p>{$vo.pfs.con}</p><br>
                        <h3>企业评语:</h3><br>
                        <volist name="co" id="co">
                            <div>
                                <p>{$key}:</p>
                                <br>
                                <volist name="co" id="f">
                                    <p>{$f['comment']}</p>
                                    <br>
                                </volist>
                            </div>
                        </volist>
                    </if>
                </div>
                <!-- 考试-评语 End -->
            </div>
            <!-- 题目列表 End -->
        </volist>
        <!-- 提交按钮 -->
        <if condition="$ms == 2">
            <div class="exam-submit">
                <button class="btn btn-primary" onclick="next()">下一个</button>
            </div>
            <elseif condition="$ms == 3" />
            <div class="exam-submit">
                <button class="btn btn-primary" onclick="history.go(-1);">返回</button>
            </div>
        </if>
    </section>
    <!-- container End -->
</div>
<div class="modal modal-exam fade" aria-hidden="true" id="share">
    <div class="icon icon-spin loader icon-spinner-indicator"></div>
    <div class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button class="close" data-dismiss="modal">×</button>
                <h4 class="modal-title">
                    <i class="modal-icon icon-undefined"></i>
                    <span class="modal-title-name">分享到朋友圈</span>
                </h4>
            </div>
            <div class="modal-body">
                <form action="" method="post" enctype="multipart/form-data" id="form1">
                    <a class="btn btn-primary btn-block btn-lg">
                        <span id="sp">上传预览图</span>
                        <input type="file" name="upfile" accept="image/png,image/gif,image/jpg" id="upfile" onchange="handleFile()">
                    </a>
                    <!-- <input type="text" disabled="disable" value="文件名"  style="text-align:center;"> -->
                    <div class="img pt-10 hide">
                        <img src="">
                    </div>
                    <p class="pt-10">图片建议比例：16:9</p>
                    <div class="pt-20">
                        <textarea class="form-control timu" rows="3" placeholder="说点什么吧。" name="said"></textarea>
                    </div>
                    <div class="text-center pt-20">
                        <buttom class="btn btn-primary" data-dismiss="modal">取消</buttom>
                        <buttom class="btn btn-primary" onclick="ajaxShare()">确认</buttom>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
<script src="__PUBLIC__/dist/js/jquery.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.qrcode/1.0/jquery.qrcode.min.js"></script>
<script>
    var file = document.getElementById("upfile");
    function handleFile() {
        if (file.value != "") {
            $("#sp").text('已选择文件');
        }
    }
</script>
<script>
    $(".btn-zan").on("click", function () {
        $(this).toggleClass("active");
        $.post("{:U('User/Student/laud')}&id={$list.exid}", function (result) {
            console.log(result);
            var num = result.replace(/"/g, "");
            $(".btn-zan").next().html("&nbsp;" + num);
        });
    });
</script>
<script>
    function ajaxShare() {
        var formData = new FormData($("#form1")[0]);
        $.ajax({
            url: "{:U('User/Student/do_share')}&id={$list.exid}",
            type: "POST",
            data: formData,
            dataType: "json",
            async: false,
            cache: false,
            contentType: false,
            processData: false,
            success: function (res) {
                $('#share').modal("hide");
                var url = res;
                var myModal = new $.zui.ModalTrigger({
                    className: "modal-exam",
                    title: "扫码分享到朋友圈",
                    size: "sm",
                    custom: '<div id="qrcode"></div><input type="text" value="' + url + '" disabled>'
                });
                myModal.show();
                $("#qrcode").qrcode(url);
            }
        });
    }
</script>
<script>
    $(".mark > a").on("click", function () {
        var myModal = new $.zui.ModalTrigger({
            className: "modal-exam",
            title: "查看题目",
            type: "ajax",
            url: "{:U('User/Teacher/AjaxExam')}&eid={$list.eid}&exid={$list.exid}",
            size: "lg",
        });
        myModal.show();
    })
    $(".mark h2 a").on("click", function () {
        var myModal = new $.zui.ModalTrigger({
            className: "modal-exam",
            title: "其他学生",
            type: "ajax",
            url: "{:U('User/Teacher/AjaxList')}&eid={$list.eid}&userid={$list.userid}",
            size: "sm",
        });
        myModal.show();
    })
    function next() {
        var arr = {};
        var isok = false;
        if ($(".exam-list-li").length == 0) {
            isok = true;
        }
        else {
            $(".exam-list-li").each(function () {
                var val = $(this).attr('data-id');
                if (val) {
                    var inp = $("#in" + val).val();
                    if (inp == '') {
                        alert('有分数为空');
                        isok = false;
                    }
                    else {
                        isok = true;
                    }
                    var tep = $("#te" + val).val();
                    if (tep == '') {
                        alert('有点评为空');
                        isok = false;
                    }
                    else {
                        isok = true;
                    }
                    arr[val] = { sco: inp, con: tep };
                }
            })
        }
        //console.log(JSON.stringify(arr));
        if (isok) {
            var kgsco = $(".exam-list").attr('data-shu');
            var data = { examnote: JSON.stringify(arr), kgsco: kgsco };
            var url = "{:U('User/Teacher/pingjuan')}&eid={$list.eid}&exid={$list.exid}";
            $.ajax({
                type: "POST",
                url: url,
                data: data,
                success: function (msg) {
                    msg = JSON.parse(msg);
                    //console.log(msg);
                    alert(msg.info);
                    //  if(msg.status==1)
                    //  {
                    //      window.location.href="{:U('User/Teacher/ExamCollect')}";
                    //  }
                    if (msg.status == 2) {
                        window.location.href = "{:U('User/Teacher/ExamMark')}&eid=" + msg.data.eid + "&nexid=" + msg.data.nexid;
                    }

                }
            });
        }
    }
</script>